<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function doCookie() {
            // document.cookie = 'name=tom'
            // document.cookie = 'sex=male'
            //
            // // 指定失效时间
            // var date = new Date()
            // date.setDate(date.getDate()+7)
            // document.cookie = 'age=18;expires='+date.toUTCString()

            var data = document.cookie
            console.log(data);
        }
        
        function doWebStorage() {
            // 写入
            // localStorage.setItem("name","jack")
            // sessionStorage.setItem("name","jack")

            // 读取
            // console.log(localStorage.getItem("name"));

            // localStorage.removeItem("name")


            var users = [
                {
                    id:1001,
                    name:'aaa',
                    age:18
                },
                {
                    id:1002,
                    name:'bbb',
                    age:18
                },
                {
                    id:1003,
                    name:'ccc',
                    age:18
                },
            ]

            // localStorage.setItem("users",JSON.stringify(users))

            // console.log(localStorage.getItem("users"));

            var data = JSON.parse(localStorage.getItem("users"))
            console.log(data);
        }

    </script>
</head>
<body>
    <button onclick="doCookie()">操作Cookie</button>
    <button onclick="doWebStorage()">操作WebStorage</button>
</body>
</html>